<?PHP
//#######################################################	
//JAVASCRIPT FOR SHOWING PREVIEW
//#######################################################		
echo"\n<script type=\"text/javascript\" src=\"../include/sarissa/sarissa.js\"></script>";
echo "\n<script language= \"JavaScript\">
<!--

function editFromPreview(){
	var url = 'index.php?op=editStory&currentID=1&ID='+storyID;
	window.location = url;
}

function deleteFromPreview(){
	var url = 'index.php?op=deleteStory&currentID=1&ID='+storyID+'&title='+storyTitle;
	window.location = url;
}

function displayMediaPlayer(soundFile){
var player = \"<!--BEGIN MP3 PLAYER--><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='300' height='75' id='mp3Player' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='../media/mp3Player.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><PARAM NAME=FlashVars VALUE='file=../media/audio/\" +soundFile+\"&autoPlayStart=true'><embed src='../media/mp3Player.swf' FlashVars='file=../media/audio/\" +soundFile+\"&autoPlayStart=true' quality='high' bgcolor='#ffffff' width='300' height='75' name='mp3Player' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object><!--END MP3 PLAYER-->\"
document.getElementById('soundClip').innerHTML = player;
}

function showPreview(ID){
//--------------AJAX
		var http_request = new XMLHttpRequest();
		http_request.onreadystatechange = function(){
			if(http_request.readyState == 4){
			
				storyID = ID;
				storyTitle = http_request.responseXML.getElementsByTagName('headline')[0].firstChild.data;
				//SUCCESS - POPULATE DIV TAG
				moveDiv('preview');
				document.getElementById('preview').style.visibility = 'visible';
				document.getElementById('headlinePreview').innerHTML = http_request.responseXML.getElementsByTagName('headline')[0].firstChild.data;
				if(http_request.responseXML.getElementsByTagName('byline')[0]){
					document.getElementById('bylinePreview').innerHTML = http_request.responseXML.getElementsByTagName('byline')[0].firstChild.nodeValue; 
				}else{
					document.getElementById('bylinePreview').innerHTML = http_request.responseXML.getElementsByTagName('copyright')[0].firstChild.nodeValue; 
				}
				
				//SOUND FILE
				if(http_request.responseXML.getElementsByTagName('soundfile')[0]){
				    mp3 = http_request.responseXML.getElementsByTagName('soundfile')[0].firstChild.data;
					document.getElementById('soundClip').innerHTML = \"<a href='#' onCLick='displayMediaPlayer(mp3)'><img src='../images/listen2.gif'></a>\";
				}else{
					document.getElementById('soundClip').innerHTML = '';
				}
				
				//IMAGE FILE
				if(http_request.responseXML.getElementsByTagName('image')[0]){
					document.getElementById('imageTable').style.width = '150px';
					var image = http_request.responseXML.getElementsByTagName('image')[0].firstChild.data;
					var imageLength = image.length;
					document.getElementById('image').innerHTML = \"<a href='../media/pictures/\"+image+ \"' TARGET='_blank'> <img src='../media/pictures/\" + image.substr(0,(imageLength-4)) + '-TN.jpg' + \"' style='float:left; margin-right:3px; margin-bottom:0px; border:1px solid #000000;'></a>\";  
				}else{
					document.getElementById('image').innerHTML = '';
					document.getElementById('caption').innerHTML = '';
					document.getElementById('credit').innerHTML = '';
					document.getElementById('imageTable').style.width = '0px';
				}
				
				
				//CAPTION
				if(http_request.responseXML.getElementsByTagName('caption')[0]){
					document.getElementById('caption').innerHTML = http_request.responseXML.getElementsByTagName('caption')[0].firstChild.data;
				}
				if(http_request.responseXML.getElementsByTagName('credit')[0]){
					document.getElementById('credit').innerHTML = 'Photo By: ' + http_request.responseXML.getElementsByTagName('credit')[0].firstChild.data;
				}
				
				document.getElementById('teasePreview').innerHTML = http_request.responseXML.getElementsByTagName('dateline')[0].firstChild.data + \" (".date("Y-m-d").") \" + http_request.responseXML.getElementsByTagName('tease')[0].firstChild.data + \"<div id='copy' style='padding-top:4px;' CLASS='article-small' >&copy; Copyright \" + \" ".date("Y").", \" + http_request.responseXML.getElementsByTagName('copyright')[0].firstChild.data + \"</div>\";  
				//document.getElementById('copy').innerHTML = '<div id='copy' style='padding-top:0px;' CLASS='article-small' >&copy; Copyright ' + ' ".date("Y").", ' + http_request.responseXML.getElementsByTagName('copyright')[0].firstChild.data + '</div>'; 



			}//end readyState
			
			
			
			
			
		}//end success function
		
		http_request.open(\"GET\", \"formaction.php?action=previewStory&ID=\" + ID, true);
		// if needed set header information 
		// using the setRequestHeader method
		http_request.send('');

//--------------AJAX
}
//-->
</script>
<link rel='stylesheet' type='text/css' media='all' href='".XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/news.css'."' />

<div id='preview' style=' POSITION: absolute; 
 left: 50%;
 margin-left: -200px;
 VISIBILITY: hidden; 
 BACKGROUND-COLOR: #E7E7E7; 
 width: 400px; 
 BORDER-LEFT: 1px solid black; 
 BORDER-TOP: 1px solid black; 
 BORDER-BOTTOM: 3px solid black; 
 BORDER-RIGHT: 3px solid black; 
 PADDING-TOP: 5px; 
 PADDING-RIGHT: 10px; 
 PADDING-LEFT: 10px; 
 PADDING-BOTTOM: 10px; 
 z-index:999;text-align:left'>
 
  <P CLASS='headline-block' style='margin:0; padding:0;'>
	 <DIV CLASS='headline-large' id='headlinePreview'></DIV>
	 <div id='bylinePreview'></div>
	 <div id='soundClip' style='margin-top:2px;'></div>
	 <table cellspacing='1' cellpadding='1' border='0' style='margin-top:10px; padding-bottom:0; margin-bottom:0;' >
	 	<TR>
			<TD id='imageTable' >
				<div id='image' style='padding-bottom:0; margin-bottom:0;'></div>
				<div id='credit' CLASS='photo-credit' ></div>
				<div id='caption' CLASS='photo-caption'>test test</div>
			</TD>
			<TD id='teasePreview' CLASS='article' ></TD>
		</TR>
	</TABLE>
  </P>

 <DIV id='buttonsPreview' style='margin-top:15px; padding:5px; border:1px #000000 solid; text-align:center; background-color:#999999'><input type='button' class='formButton' name='Edit'  id='edit' value='Edit' onclick=\"editFromPreview()\" /> &nbsp; &nbsp; <input type='button' class='formButton' name='delete'  id='delete' value='Delete' onclick=\"deleteFromPreview()\" /> &nbsp; &nbsp; <input type='button' class='formButton' name='hide'  id='hide' value='Hide' onclick=\"document.getElementById('preview').style.visibility = 'hidden'\" /></DIV>
 </div> ";	
?>